package timing.ukulele.project.client;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import timing.ukulele.project.client.callback.FlowClientCallback;
import timing.ukulele.common.ResponseResult;
import timing.ukulele.common.flow.FlowData;
import timing.ukulele.common.vo.ExecuteVO;
import timing.ukulele.common.vo.TaskVO;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@FeignClient(value = "ukulele-flow", path = "flow", fallback = FlowClientCallback.class)
public interface FlowClient {
    @PostMapping("/api/flow/publicCompleteTask")
    ResponseResult<String> publicCompleteTask(@RequestBody ExecuteVO executeVO);

    @PostMapping("/api/flow/startFirstComplete")
    ResponseResult<String> startFirstComplete(@RequestBody ExecuteVO executeVO);

    @GetMapping("/api/flow/getById/{id}")
    ResponseResult<FlowData> getById(@PathVariable("id") Long id);

    @GetMapping("/api/flow/instance/{id}")
    ResponseResult<TaskVO> getInstanceTask(@PathVariable("id") String id);

    @GetMapping("/api/flow/HistoryTasks/{instanceId}")
    ResponseResult<List<TaskVO>> getHistoryTasksByInstanceId(@PathVariable("instanceId") String instanceId);

    @PostMapping("/api/flow/findUndoTaskByAssignee")
    ResponseResult<Page<TaskVO>> findUnDoTaskByAssignee(@ApiParam("代理人（用户）") @RequestParam(value = "assignee", required = false) String assignee,
        @ApiParam("租户id") @RequestParam("tenantId") String tenantId,
        @ApiParam(value = "变量名") @RequestParam(value = "variableName", required = false) String variableName,
        @ApiParam(value = "变量值") @RequestParam(value = "variableValue", required = false) String variableValue,
        @ApiParam(value = "流程实例id") @RequestParam(value = "processInstanceId", required = false) String processInstanceId,
        @ApiParam(value = "创建时间排序方向:1代表时间升序、-1代表时间降序") @RequestParam("sort") Integer sort,
        @ApiParam(value = "当前页码", example = "1") @RequestParam("current") Integer current,
        @ApiParam(value = "每页大小", example = "10") @RequestParam("pageSize") Integer pageSize);
}
